<?php

namespace Admin\Model;

use Think\Model;

/**
* 订单模型
*/
class GuestModel extends Model
{
	/**
	 * [订单列表]
	 * @param  string $range 筛选日期范围 1本日，2本月
	 * @return [type]         [description]
	 */
	public function showlist($range){
		switch ($range) {
			case '1':
				$where['create_time'] = array('gt',strtotime(date('Y-m-d',time())));
				break;
			case '2':
				$where['create_time'] = array('gt',strtotime(date('Y-m',time())));
				break;
		}
		//分页
		$count = $this -> where($where) -> count();
		$page = new \Think\Page($count, 10);
		$page -> setConfig('theme','%FIRST% %UP_PAGE% %LINK_PAGE% %DOWN_PAGE% %END% %HEADER%');
		$pages = $page -> show();		

		$list = $this -> order('id desc') -> where($where) -> limit($page->firstRow, $page->listRows) -> select();
		return array($list,$pages);
	}

	// public function edit($id,$val,$flag){
	// 	$where['id'] = is_array($id) ? array('in',implode(',', $id)) : $id;
	// 	return $this -> where($where) -> save(array($flag => $val));
	// }
}